# -*- coding: utf-8 -*-
# @Time    : 2024/2/24
# @Author  : Yangyali
#
from tools import Global
from loguru import logger
import requests
class Request:
    headers = {"Token": Global.token}
    print("hha")
    print(headers)
    def send_request(self,method,url,data=None,header=None):
        url=Global.base_url+url
        if header==None:
            header=self.headers
        try:
            if method.upper() == "GET":
                response = requests.get(url, params=data, headers=header)
                return response
            elif method.upper() == "POST":
                response = requests.post(url, data=data, headers=header)
            else:
                # print("输入的请求方法不对")
                logger.info("输入的请求方法不对")
        except Exception as e:
            # print("请求报错了:{0}".format(e))
            logger.error("请求报错了:{0}".format(e))
            raise e

Req=Request()